package bishi.kaizi;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2022/03/12 16:55
 */
public class _05 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] dui = new int[n];
        for (int i = 0; i < n; i++) {
            dui[i] = i + 1;
        }
        int[] nums = new int[m];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = sc.nextInt();
        }
        boolean[] bs = new boolean[m];
        int num = 0;
        int res = 0;
        for (int i = 0; i < m; i++) {
            if (!bs[nums[i]]) {
                if (num == n - 1) {
                    res++;
                    num = 0;
                    bs = new boolean[m];
                } else {
                    num++;
                    bs[nums[i]] = true;
                }
            }
        }
        System.out.println(res);
    }
}
//2 3 1 3 2 1 1 2 3 1
//   2 2 3 3 3 3 2 2